import java.rmi.RemoteException;
import java.util.Calendar;
import java.util.Date;
import java.util.UUID;

import general.Product;
import general.ProductPrice;
import general.ProductRequest;
import net.jini.core.lease.Lease;
import net.jini.core.transaction.TransactionException;
import net.jini.space.JavaSpace;

public class SpaceTestings {
	public static void main(String[] args) {
		JavaSpaceLookup lookup = new JavaSpaceLookup();
		JavaSpace fSpace = null;
		try {
			fSpace = lookup.getSpace(new String[] { "SEB" });
		} catch (Exception e) {
			e.printStackTrace();
		}

		Calendar cd = Calendar.getInstance();
		cd.add(Calendar.MINUTE, 1);
		Date endTime = cd.getTime();
		Product p = new Product("Product1");
		ProductPrice pr = new ProductPrice(0);
		UUID u = UUID.randomUUID();
		ProductRequest item = new ProductRequest(u, endTime, pr, p);
		try {
			Date d = new Date();
			fSpace.write(item, null, endTime.getTime()-d.getTime());
		} catch (RemoteException e) {
			e.printStackTrace();
		} catch (TransactionException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
